'use strict'

const {DataTypes, Model, Op } = require('../../../azeroth').sequelize;
class station extends Model {}

const initStation = (sequelize_aim) => {
  station.init(
    {
        id: {
            autoIncrement: true,
            type: DataTypes.INTEGER,
            allowNull: false,
            primaryKey: true
          },
        station_name: {
            type: DataTypes.STRING,
            allowNull: true
        },
        station_id: {
            type: DataTypes.INTEGER,
            allowNull: true
        },
        flaw_class_type: {
            type: DataTypes.STRING,
            allowNull: true
        }
    },
    {
      freezeTableName: true,
      sequelize: sequelize_aim,
      modelName: 'station',
      timestamps: false
    }
  )
}

station.upload = async (data) => {
  let res = await station.bulkCreate(data, {
    updateOnDuplicate: ['id', 'flaw_class_type', 'station_name', 'station_id']
  });
  return res;
}

module.exports = {
  station,
  initStation
};